<template>
  <div class="ele-exception ele-text-center">
    <div class="ele-exception-img">
      <img src="@/assets/ic-404.svg" alt="" width="305px" height="245px">
    </div>
    <div class="ele-exception-content ele-text-left">
      <h1 class="ele-text">404</h1>
      <p class="ele-text-secondary">抱歉，你访问的页面不存在</p>
      <div>
        <router-link to="/">
          <el-button type="primary" @click="goHome">返回首页</el-button>
          <el-button type="primary" @click="goLogin">返回登录</el-button>
        </router-link>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Exception404',
  data() {
    return {
      countdown: 3
    }
  },
  components: {

  },
  mounted() {
    this.goLogin()
  },
  methods: {
    goHome(){
      const timer = setInterval(() => {
          this.countdown--
          if (this.countdown <= 0) {
            clearInterval(timer)
            //this.$router.push('/target-page')
            this.$store.dispatch('user/removeToken').then(() => {
              location.replace('/login');
            });
          }
      }, 1000)

    },
    goLogin() {
      console.log('--------------go----home')
      const query = this.$route.query;
      const path = query && query.from ? query.from : '/';
      this.$router.push(path).catch(() => {});
    }
  }
}
</script>
